package library;

import javax.ejb.Stateless;

import library.IF.LibraryAdminIF;

/**
 * The Class LibraryAdminBean.
 */
@Stateless
public class LibraryAdminBean implements LibraryAdminIF
{
	
	/**
	 * Instantiates a new library admin.
	 */
	public LibraryAdminBean()
	{
		System.out.println("LibraryAdminBean()");
	}
	
	/**
	 * Check.
	 * 
	 * @param usr the usr
	 * @param pwd the pwd
	 * 
	 * @return the string[]
	 */
	public String[] check(String usr, String pwd)
	{
		System.out.println("LibraryAdminBean.check(" + usr + ", " + pwd + ")");
		LibraryPrincipal principal = LibraryPrincipal.findLibraryPrincipal(usr);
		if (principal != null && pwd.equals(principal.getPassword()))
		{
			return principal.getRoles();
		}
		return null;
	}
}
